Populate a tree control

C# .NET

public static void DoTest()
{

         // Create a new instance of the form.
         Form form1 = new Form();

         // Create a tree control
         TreeView tree = new TreeView();
         // Add sonme nodes to the tree
         TreeNode nodeParent, nodeChild;
         nodeParent = tree.Nodes.Add("Item 1");
         nodeChild = nodeParent.Nodes.Add("Item 11");
         nodeChild = nodeParent.Nodes.Add("Item 12");
         nodeChild = nodeParent.Nodes.Add("Item 13");
         nodeParent = tree.Nodes.Add("Item 2");
         nodeChild = nodeParent.Nodes.Add("Item 21");
         nodeChild = nodeParent.Nodes.Add("Item 22");
         nodeChild = nodeParent.Nodes.Add("Item 23");



         tree.ExpandAll();
         // Set the caption bar text of the form.
         form1.Text = "My Dialog Box";
         // Define the border style of the form to a dialog box.
         form1.FormBorderStyle = FormBorderStyle.FixedDialog;
         // Set the start position of the form to the center of the screen.
         form1.StartPosition = FormStartPosition.CenterScreen;

         // Add tree to the form.
         form1.Controls.Add(tree);

         // Display the form as a modal dialog box.
         form1.ShowDialog();
}

 

Blaze++ .NET

static void DoTest()
{

         // Create a new instance of the form.
         Form form1;

         // Create a tree control
         TreeView tree;
         // Add sonme nodes to the tree
         TreeNode nodeParent, nodeChild;

         nodeParent = tree.Nodes.Add("Item 1");
         nodeChild = nodeParent.Nodes.Add("Item 11");
         nodeChild = nodeParent.Nodes.Add("Item 12");
         nodeChild = nodeParent.Nodes.Add("Item 13");

         nodeParent = tree.Nodes.Add("Item 2");
         nodeChild = nodeParent.Nodes.Add("Item 21");
         nodeChild = nodeParent.Nodes.Add("Item 22");
         nodeChild = nodeParent.Nodes.Add("Item 23");
         // expand all branches
         tree.ExpandAll();

         // Set the caption bar text of the form.
         form1.Text = "My Dialog Box";
         // Define the border style of the form to a dialog box.
         form1.FormBorderStyle = FormBorderStyle::FixedDialog;
         // Set the start position of the form to the center of the screen.
         form1.StartPosition = FormStartPosition::CenterScreen;

         // Add tree to the form.
         form1.Controls.Add(tree);




         // Display the form as a modal dialog box.
         form1.ShowDialog();
}